package com.study.dubbo.service.zipkin.dubbo;

import brave.Tracing;
import brave.sampler.Sampler;
import com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory;
import zipkin2.Endpoint;
import zipkin2.reporter.AsyncReporter;
import zipkin2.reporter.okhttp3.OkHttpSender;

/**
 * @author lin
 * @create 2018-08-07 11:45
 **/
public class TracingFactory extends SpringExtensionFactory {
    @Override
    public <T> T getExtension(Class<T> type, String name) {
        if (type != Tracing.class) return null;
        return (T) Tracing.newBuilder().spanReporter(AsyncReporter.builder(OkHttpSender.create("http://192.168.120.128:9411/api/v2/spans")).build()).endpoint(Endpoint.newBuilder().ip("127.0.0.1:8081").build()).sampler(Sampler.ALWAYS_SAMPLE).build();
    }

//    private Brave brave;
}
